
public class Solution {
    public static void main(String[] args) {
        int k = 6;
        int[] a = {-2, 11, -4, 13, -5, -2};
        int sum = 0;
        int numtimes = 0;
        for (int i = 0; i < k; i++) {
            int temp = 0;
            int times = 0;
            for (int j = i; j < k; j++) {
                temp += a[j];
                times = a[j] >= 0 ? times++ : times--;
                if (sum < temp) {
                    sum = temp;
                    numtimes = times;
                }
            }
        }
        if (numtimes < 0) {
            System.out.println(0);
        } else {
            System.out.println(sum);
        }
    }
}
